home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 8973 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.4 KB  |  42 lines

  1. Path: library.erc.clarkson.edu!rpi!not-for-mail
  2. From: Rick Richert <richert@butch.lmsc.lockheed.com>
  3. Newsgroups: comp.lang.c++,comp.lang.c++.moderated
  4. Subject: Argc & Argv
  5. Date: 26 Feb 1996 21:55:59 -0000
  6. Organization: Org. 81-20
  7. Sender: cppmods@netlab.cs.rpi.edu
  8. Approved: Dietmar.Kuehl@uni-konstanz.de
  9. Message-ID: <4gta9f$df5@netlab.cs.rpi.edu>
  10. NNTP-Posting-Host: netlab.cs.rpi.edu
  11. X-Original-Date: 26 Feb 1996 21:49:43 GMT
  12.  
  13. >>  I tried posting this last week and am not sure if it was posted or
  14. >>  not.  Soooo, I'm trying again.
  15.  
  16. I have some global objects defined outside the main routine and I would
  17. like to pass the argc and argv values to their constructors.  For example,
  18.  
  19.  
  20. SomeClass obj( argc, argv);
  21.  
  22. int main( int argc, char **argv) {
  23.  
  24.    blah, blah, blah
  25.  
  26. }
  27.  
  28. Unfortunately, the compiler tells me that argc and argv are not defined
  29. or else not available for obj.
  30.  
  31. Currently, I get around this problem by creating the global obj and then
  32. inside of main, I initialize obj via a method that takes argc and argv.  
  33.  
  34. I would prefer to pass the arg vars to the constructor.  Does anyone know
  35. how I can pass the arg vars without being inside of main?
  36.  
  37.  
  38.       [ Articles to moderate: mailto:c++-submit@netlab.cs.rpi.edu ]
  39.       [  Read the C++ FAQ: http://www.connobj.com/cpp/cppfaq.htm  ]
  40.       [  Moderation policy: http://www.connobj.com/cpp/guide.htm  ]
  41.       [      Comments? mailto:c++-request@netlab.cs.rpi.edu       ]
  42.